package com.lfc.guavaobserver;

import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;

import java.util.List;
import java.util.concurrent.Executors;

public class UserController {
    private EventBus eventBus;
    public UserController(){
        // 在类初始化的时候创建一个线程对象
        eventBus=new AsyncEventBus(Executors.newFixedThreadPool(2));
    }

    /**
     * 注册调用的事件类型
     * @param observerList
     */
    public void setObserverList(List<Object> observerList){
        for (Object  obj: observerList) {
            eventBus.register(obj);
        }
    }
    public void register(String useName){
        eventBus.post(useName);
    }


}
